package org.biubiu0002.baiblog.core.controller;

import org.biubiu0002.baiblog.common.utils.PageUtils;
import org.biubiu0002.baiblog.common.utils.R;
import org.biubiu0002.baiblog.core.model.entity.FavorRecordEntity;
import org.biubiu0002.baiblog.core.service.FavorRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 收藏记录表
 *
 * @author biubiu0002
 * @email 1007918011@qq.com
 * @date 2022-05-06 00:50:37
 */
@RestController
@RequestMapping("/favorrecord")
public class FavorRecordController {
    @Autowired
    private FavorRecordService favorRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("core:favorrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = favorRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("core:favorrecord:info")
    public R info(@PathVariable("id") Long id){
		FavorRecordEntity favorRecord = favorRecordService.getById(id);

        return R.ok().put("favorRecord", favorRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("core:favorrecord:save")
    public R save(@RequestBody FavorRecordEntity favorRecord){
		favorRecordService.save(favorRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("core:favorrecord:update")
    public R update(@RequestBody FavorRecordEntity favorRecord){
		favorRecordService.updateById(favorRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("core:favorrecord:delete")
    public R delete(@RequestBody Long[] ids){
		favorRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
